home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / SourceCode / OOP_Course / Examples / DrawTests / DPSUserPath / MouseView.m < prev    next >
Text File  |  1992-12-19  |  2KB  |  88 lines

  1. /*
  2.  *    MouseView --  John Glover, adapted from MouseTracker by Randy Nelson
  3.  *    An abstract class that manages a modal loop for tracking the mouse
  4.  *
  5.  */
  6.  
  7. #import "MouseView.h"
  8. #import <appkit/Window.h>
  9. #import <appkit/Application.h>
  10. #import <appkit/Control.h>
  11. #import <dpsclient/psops.h>
  12. #import <dpsclient/wraps.h>
  13.  
  14. @implementation MouseView
  15.  
  16.  
  17.  
  18. - setTrackingRect:sender
  19. {
  20.     NXRect myFrame = frame;
  21.     [[self superview] convertRect:&myFrame toView:nil];
  22.     [window setTrackingRect:&myFrame
  23.         inside:NO
  24.         owner:self
  25.         tag:23
  26.         left:NO
  27.         right:NO];
  28.     return self;
  29. }
  30.  
  31. - mouseDown:(NXEvent *)e
  32.  {
  33.     NXPoint startPoint = e->location, nextPoint;
  34.     int looping = YES;
  35.     int oldMask = [window addToEventMask:NX_MOUSEDRAGGEDMASK];
  36.     
  37.     /* do first mouse down action */
  38.     [self convertPoint:&startPoint fromView:nil];
  39.     [self mouseDownAction:&startPoint];
  40.     
  41.     while (looping){
  42.     e = [NXApp getNextEvent:NX_MOUSEUPMASK|NX_MOUSEDRAGGEDMASK];
  43.     nextPoint = e->location;
  44.     [self convertPoint:&nextPoint fromView:nil];
  45.     if(e->type == NX_MOUSEDRAGGED){
  46.         [superview autoscroll:e];
  47.  
  48.         /* do continuing mouse dragged action */
  49.         [self mouseDraggedAction:&nextPoint];
  50.     }
  51.     else{
  52.         looping = NO;
  53.  
  54.         /* do mouse up action */
  55.         [self mouseUpAction:&nextPoint];
  56.     }    
  57.     }
  58.     [window setEventMask:oldMask];
  59.     return self;
  60.  }
  61.  
  62. - mouseEntered:(NXEvent *)e
  63. {
  64.     return [super mouseEntered:e];
  65. }
  66.  
  67. - mouseExited:(NXEvent *)e
  68. {
  69.     return [super mouseExited:e];
  70. }
  71.  
  72. - mouseDownAction:(NXPoint *)currentLocation
  73. {    
  74.     return self;
  75. }
  76.  
  77. - mouseDraggedAction:(NXPoint *)currentLocation
  78. {
  79.     return self;
  80. }
  81.  
  82. - mouseUpAction:(NXPoint *)currentLocation
  83. {
  84.     return self;
  85. }
  86.  
  87. @end
  88.